/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
function HttpRequest() {
    this.url = "";
    this.submit = "";
}
HttpRequest.prototype.getUrl = function() {
    return this.url;
}
HttpRequest.prototype.getSubmit = function() {
    return this.submit;
}
HttpRequest.prototype.setUrl = function(url) {
    this.url = url;
}
HttpRequest.prototype.setSubmit = function(submit) {
    this.submit = submit;
}
HttpRequest.prototype.asynEval = function ()
{
    var xmlHttpReq = false;
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        xmlHttpReq = new XMLHttpRequest();
        //xmlHttpReq.overrideMimeType('text/plain; charset=UTF-8');
    }
    // IE
    else {
        if (window.ActiveXObject) {
            xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
            alert("pass MS1");
        }
    }
    xmlHttpReq.open('POST', this.url, true);
    xmlHttpReq.setRequestHeader('Content-Type','text/plain; charset=UTF-8');
    xmlHttpReq.onreadystatechange = function() {
        if (xmlHttpReq.readyState == 4) {
            var txt = xmlHttpReq.responseText;
            eval(txt);
        }
    }
    xmlHttpReq.send(this.submit);
}
    
HttpRequest.prototype.synchronize = function () {
    var xmlHttpReq = false;
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        xmlHttpReq = new XMLHttpRequest();
        //xmlHttpReq.overrideMimeType("text/plain; charset=UTF-8");
    }
    // IE
    else {
        if (window.ActiveXObject) {
            xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
            //alert("pass MS2");
        }
    }
    xmlHttpReq.open("POST", this.url, false);
    xmlHttpReq.setRequestHeader("Content-Type","text/xml; charset=UTF-8");
    xmlHttpReq.send(this.submit);
    var txt = xmlHttpReq.responseText;
    return txt;
}

HttpRequest.prototype.synchroniEval = function () {
    try {
    var xmlHttpReq = false;
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        //alert("pass22");
        xmlHttpReq = new XMLHttpRequest();
        //xmlHttpReq.overrideMimeType("text/plain; charset=UTF-8");
        //alert("pass23");
    }
    // IE
    else {
        //alert("pass MS31");
        if (window.ActiveXObject) {
            xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
            //alert("pass MS3");
        }
    }
    xmlHttpReq.open("POST", this.url, false);
    xmlHttpReq.setRequestHeader("Content-Type","text/xml; charset=UTF-8");
    xmlHttpReq.send(this.submit);
    var txt = xmlHttpReq.responseText;
    //alert(txt.toString());
    eval(txt);
    //var inum = 0;
    //if( service == null ) {
    //    alert("service is null");
    //} else {
    //    alert("service is not null");
    //}
    //service.print();
    //eval("inum = 1 + 3;");
    //alert("ans:"+ inum);
    } catch(err) {
        alert(err);
    }
}

HttpRequest.prototype.synchronizeXML = function () {
    var xmlHttpReq = false;
    // Mozilla/Safari
    if (window.XMLHttpRequest) {
        xmlHttpReq = new XMLHttpRequest();
        //xmlHttpReq.overrideMimeType("text/plain; charset=UTF-8");
    }
    // IE
    else {
        if (window.ActiveXObject) {
            xmlHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
            //alert("pass MS4");
        }
    }
    xmlHttpReq.open("POST", this.url, false);
    xmlHttpReq.setRequestHeader("Content-Type","text/xml; charset=UTF-8");
    xmlHttpReq.send(this.submit);
    var xmlDoc = xmlHttpReq.responseXML;
    return xmlDoc;
}
function initBroker(Url) {
    var httpRequest = new HttpRequest();
    httpRequest.setUrl(Url);
    httpRequest.setSubmit("");
    //httpRequest.asynEval();
    httpRequest.synchroniEval();
}
function loadAjax(strSubmit) {
    var httpRequest = new HttpRequest();
    httpRequest.setUrl("");
    httpRequest.setSubmit(strSubmit);
    httpRequest.synchroniEval();
}
